<?php
declare(strict_types=1);

namespace App\Jobs\RoomPK;


use App\Exceptions\BasicException;
use App\Jobs\Job;
use App\Repositories\RoomPk\RoomPKPitRepository;

class PitFinishJob extends Job
{
    public $pkId;

    public function __construct(int $pkId)
    {
        $this->pkId = $pkId;
    }

    /**
     * @throws BasicException
     */
    public function handle()
    {
        try {
            RoomPKPitRepository::getInstance()->finish($this->pkId);
        }catch (\Exception $e){
            file_put_contents(
                storage_path() . '/logs/pk-job-' . date('Ymd') . '.log',
                "name: PitFinishJob, message: {$e->getMessage()}, line: {$e->getLine()}, file: {$e->getFile()}" . PHP_EOL, FILE_APPEND
            );
        }
    }

}